#include<iostream>
#include<ostream>
using std::cout;
using std::endl;
using std::ostream;

class Point{

//Auto
class AutoRelease{
    public:
        AutoRelease()
        {
            cout<<"AutoRelease (Point* p)"<<endl;
        }
        ~AutoRelease(){
            if(_point){
                delete _point;
                _point = nullptr;
            }
        }
    }; 

public:
    static Point* Instance(int x,int y){
        if(_point == nullptr){
            _point = new Point(x,y);
        }
        return _point;
    }
    friend
    ostream& operator<<(ostream &ofs,const Point &rhs);
    void destory(){
        if(_point){
        delete _point;
         _point = nullptr;
        }
    }
private:
    Point(int x,int y)
    :_x(x)
    ,_y(y)
    {}
    ~Point(){
        cout<<"~point"<<endl;
    }
    Point(const Point&rhs) = delete;
    Point& operator= (const Point&rhs) = delete;
private:
    int _x;
    int _y;
    static Point* _point;
    static AutoRelease * Atuo;
};
Point* Point::_point = nullptr;
Point::AutoRelease* Point::Atuo = nullptr;
//<<
ostream& operator<<(ostream &ofs,const Point &rhs){
    ofs<<"Point :"<<rhs._x<<" "<<rhs._y;
    return ofs;
}


int main(void){

    Point::Instance(3,4);  
    Point::Instance(3,4)->destory();
    //AutoRelease Autto(p);
}